// 渲染
function getUrlParams() {
    let url = location.href;
    let regExp = /.*\?([^\?]+)/
    let query = {};//最终处理好的参数
    let search = regExp.exec(url);
    //productid=23&NAME=123"
    // console.log(search);
    search = search[1];
    //有没有多个query参数,有的话肯定以&进行连接
    let searchArr = [];
    if (search.indexOf("&")) {
        searchArr = search.split("&")
    } else {
        search = search.split()
    }

    searchArr.forEach(item => {
        let queryArr = item.split("=");
        query[queryArr[0]] = queryArr[1]
    })

    return query
}

let query = getUrlParams();
// console.log(query)
let uu = document.querySelector(".content")
//http://chst.vip:1234/api/getbrandproductlist?brandtitleid=0&pagesize=10
$.ajax({
    url: `http://chst.vip:1234/api/getbrandproductlist?brandtitleid=${query.brandid}&pagesize=10`
}).then(res => {
    let html = ""
    console.log(res)

    let subNav = document.querySelector("#subNav")
    let aaa = document.querySelector(".aaa")
    // console.log(query.title);
    var t = decodeURI(query.title);
    console.log(t);
    aaa.innerHTML = t

    res.result.forEach(item => {

        html += ` <li>
        <a href="">
        <div class="img">
        ${item.productImg}
        </div>
        <div class="info">
        <div class="title">
            <h4>${item.productName}</h4>
            <div class="price">${item.productPrice}</div>
        </div>
        <div class="other">
            <span>${item.productQuote}</span>
            <span>${item.productCom}</span>
        </div>
    </div>
</a>
</li>`
    })
    uu.innerHTML = html

})